package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品ID查询套餐
     * @param ids
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> ids);

    /**
     * 新增套餐-插入菜品
     * @param setmealDishList
     */
    void insert(List<SetmealDish> setmealDishList);

    /**
     * 批量删除套餐内菜品
     * @param ids
     * @return
     */
    void delete(List<Long> ids);

    /**
     * 根据套餐id查询对应菜品
     * @param id
     * @return
     */
    @Select("select * from sky_take_out.setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getDishBysetmealId(Long id);

    @Select("select d.* from dish d left join setmeal_dish s on d.id= s.dish_id where setmeal_id=#{id}")
    List<Dish> getdishById(Long id);
}
